package com.huangliusong.desigin.pattern.creational.singleton;



import com.mysql.jdbc.StringUtils;


import java.util.HashMap;
import java.util.Map;

/**
 * @author huangliusong
 * @since 2018/10/11
 * {@link Map}
 */
public class ContainerSingleton {
    private ContainerSingleton(){

    }
    private static Map<String,Object> singleton=new HashMap<String, Object>();


    public static void putInstance(String key, Object instance){
         if (StringUtils.isNullOrEmpty(key)&&instance!=null){
            if (!singleton.containsKey(key)){
                singleton.put(key,instance);
            }
        }
    }


    public static java.lang.Object getInstance(String key){
        return singleton.get(key);
    }
}
